#!/bin/sh

# Slackware build script for Keychain

# Written by Menno Duursma <druiloor@zonnet.nl>

# This program is free software. It comes without any warranty.
# Granted WTFPL, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.

PRGNAM=keychain
VERSION=2.7.0
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
cd $PRGNAM-$VERSION
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

make all

install -D -m 0755 keychain $PKG/usr/bin/keychain
install -D -m 0644 keychain.1.gz $PKG/usr/man/man1/keychain.1.gz

install -D -m 0644 img/keychain-1.png $PKG/usr/share/pixmaps/keychain-1.png
install -D -m 0644 img/keychain-2.png $PKG/usr/share/pixmaps/keychain-2.png
# For creating a KDE desktop-entry maybe read this post:
# http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-12/msg02640.html

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a COPYING.txt ChangeLog README.rst keychain.txt $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README$TAG

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
